<!DOCTYPE html>
<html>

<head>
    <include file="public@head" title="首页" keywords="{$site_info.site_seo_keywords}"
             description="{$site_info.site_seo_description}"/>
</head>

<body>
<include file="public@header"/>
<div class="layui-carousel text-center" id="carousel-index">
    <div carousel-item>
        <foreach name=":get_slide('index_carousel')" item="vo">
            <div><a href="{$vo.url}"><img src="{$vo.thumb}" alt="{$vo.title}"></a></div>
        </foreach>
    </div>
</div>
<hr class="bg-transparent">
<div class="layui-container">
    <div class="layui-row layui-col-space10" id="articles">
        <foreach name="articles" item="vo">
            <div class="layui-col-md6">
                <article id="{$vo.id}" class="card">
                    <div class="post-head">
                        <h2 class="post-title">
                            <a href="{$vo.link}" target="_blank" title="{$vo.excerpt}">{$vo.title}</a>
                        </h2>
                        <div class="post-meta">
                            <span class="author">作者：<a href="http://www.zzuyxg.top">Eric</a></span> •
                            <time class="post-date" datetime="{$vo.create_time}" title="{$vo.create_time}">
                                {$vo.create_time}
                            </time>
                        </div>
                    </div>
                    <div class="post-excerpt">
                        <p>{$vo.excerpt}</p>
                    </div>
                    <div class="post-footer">
                        <div class="pull-right">
                            <a href="{$vo.link}" target="_blank" title="{$vo.excerpt}"
                               class="layui-btn layui-btn-primary">阅读全文</a>
                        </div>
                    </div>
                </article>
            </div>
        </foreach>
    </div>
</div>
<include file="public@footer"/>
<script>
    layui.use(['flow', 'jquery', 'carousel'], function () {
        var flow = layui.flow,
            $ = layui.jquery;

        let carousel = layui.carousel;

        carousel.render({
            elem: '#carousel-index'
            , width: '100%'
            , arrow: 'always'
        });

        flow.load({
            elem: '#articles',
            isAuto: false,
            end: '别拉了，就写了这么多~只有' + {$count} + '条',
            done: function (page, next) {
                var lis = [];
                $.get("{:url('index/get_article_flow')}?&page=" + page, function (res) {
                    layui.each(res.data, function (index, item) {
                        var html = '<article id="' + item.id + '" class="card">';
                        html += '<div class="post-head"><h2 class="post-title"><a href="' + item.link + '" target="_blank" title="' + item.title + '">' + item.title + '</a></h2>';
                        html += '<div class="post-meta"><span class="author">作者：<a href="http://www.zzuyxg.top">Eric</a></span> •<time class="post-date" datetime="' + item.create_time + '" title="' + item.create_time + '">' + item.create_time + '</time></div></div>';
                        html += '<div class="post-excerpt"><p>' + item.excerpt + '</p></div>';
                        html += '<div class="post-footer"><div class="pull-right"><a href="' + item.link + '" target="_blank" title="' + item.title + '" class="layui-btn layui-btn-primary">阅读全文</a></div></div>';
                        html += '</article>';
                        lis.push(html);
                    });
                    next(lis.join(''), page < res.pages);
                });
            }
        });
    });
</script>
</body>

</html>
